package ar.edu.itba.it.paw.web.converter;

import java.util.Locale;

import org.apache.wicket.util.convert.IConverter;

import ar.edu.itba.it.paw.domain.User;
import ar.edu.itba.it.paw.repo.UserRepo;

public class UserConverter implements IConverter{

	UserRepo userRepo;
	
	public UserConverter(UserRepo userRepo){
		this.userRepo = userRepo;
	}
	
	@Override
	public Object convertToObject(String value, Locale locale) {
		return userRepo.getUser(value);
	}

	@Override
	public String convertToString(Object value, Locale locale) {
		return ((User)value).getUsername();
	}

}
